package xyz.jangle.base;
/**
 * 匿名类
 * @author Administrator
 *
 */
public class Example6_2 {

	public static void main(String[] args) {
		Speak speak = new Speak() {
			public void speakHello() {
				System.out.println("大家好");
			}
		};
		speak.speakHello();
		
		Student student = new Student();
		student.f(new Speak() {
			@Override
			public void speakHello() {
				System.out.println("hello");
			}
		});
		
		IStudent iStudent = new IStudent() {
			@Override
			public void speakHi() {
				System.out.println("Hi");
			}
		};
		iStudent.speakHi();
	}
	
}

abstract class Speak{
	public abstract void speakHello();
}

class Student{
	void f(Speak sp) {
		sp.speakHello();
	}
}

interface IStudent{
	public void speakHi();
}